package com.xb.loan.usercenter.user.server;

import com.xb.loan.util.SpringHelper;
import com.xb.loan.util.log.DefaultLoggerFacotry;
import com.xb.loan.util.log.LogFormatUtil;
import org.slf4j.Logger;

import java.io.IOException;

/**
 *
 * 项目名称 : service-usercenter-biz
 * 类  描  述 : 启动前端使用的dubbo服务端
 */
public class StartUserCenter {
    private static final Logger logger = DefaultLoggerFacotry.getLogger(StartUserCenter.class);

    public static void main(String[] args) throws IOException {
        logger.info(LogFormatUtil.getFormatTemplate(new String[]{"method" , "msg"}) ,
                new String[]{"StartUserCenter.main" , "UserCenter provider start"});
        
        try {
            
            //加载spring配置文件
            SpringHelper.init(new String[] { "classpath:/spring/applicationContext.xml" });

           /* LoginInfoVO vo = new LoginInfoVO();
            vo.setSessionId("AVmzlQjyKFbSyPnucG90Uiao");
            vo.setUserId("201709071821430001");
            vo.setToken("AVmzlQjyKFbSyPnucG90Uiao");
            DefaultCacheFactory.getFacotry().getCache().setBean(LoginInfoVO.class,vo.getSessionId(),vo);*/

            /**TaskScheduleManager taskManager = SpringHelper.getBean("taskScheduleManager");
			
			LogConfig logConfig = SpringHelper.getBean("logConfig");
			taskManager.shedule("UserLogTask", UserLogTask.class, logConfig.getSaveLogCron(), null);


             *   去掉订单业务模块，以后添加自己处理业务模块

			//FundConfig fundConfig = SpringHelper.getBean("fundConfig");
			//taskManager.shedule("CashEncashTask", CashEncashTask.class, fundConfig.getEncashCron(), null);
			
			PropertyConf propertyConf = SpringHelper.getBean("propertyConf");
			taskManager.shedule("StatOnlineUserTask", StatOnlineUserTask.class, propertyConf.getOnlineUserCron(), null);
             */
            logger.info(LogFormatUtil.getFormatTemplate(new String[]{"method" , "msg"}) ,
                    new String[]{"StartUserCenter.main" , "SpringHelper.init end"});
            
            synchronized(StartUserCenter.class){
                //等待
                StartUserCenter.class.wait();
            }
        } catch (Exception e) {
            
        	logger.error(LogFormatUtil.getFormatTemplate("UserCenter start have happened exception") + e.getMessage());
        	e.printStackTrace();
        }
    }

}
